package com.ucode.cgms.service;

import com.ucode.cgms.mapper.CgmsCompanionOfflineOrderReportMapper;
import com.ucode.model.cgms.CgmsCompanionOfflineOrderReport;
import com.ucode.model.cgms.enums.CgmsSysResultCodeEnum;
import com.ucode.springboot.starter.mybatis.core.base.BaseService;
import com.ucode.tool.base.enums.GlobalResultCodeEnum;
import com.ucode.tool.exception.UcodeServiceException;
import cn.hutool.core.util.ObjectUtil;

import java.util.Collection;
import java.util.List;

/**
 * 陪玩线下订单报备服务接口
 * @Author: liliang
 * @Date: 2025/5/11 14:30
 * @Version: 1.0
 */
public interface CgmsCompanionOfflineOrderReportService extends BaseService<Long, CgmsCompanionOfflineOrderReport, CgmsCompanionOfflineOrderReportMapper> {

    /**
     * 审核报备
     * @param id 报备ID
     * @param auditStatuz 审核状态
     * @param processorId 处理人ID
     * @param processorType 处理人类型
     * @param processRemark 处理备注
     * @return 是否成功
     */
    public boolean auditReport(Long id, Integer auditStatuz, Long processorId, Integer processorType, String processRemark);

    /**
     * 逻辑删除
     * @param id 主键
     * @return 影响行数
     */
    default int logicDelete(Long id) {
        return this.logicDeletePrimaryKey(id);
    }
    
    /**
     * 批量逻辑删除
     * @param ids 主键集合
     * @return 影响行数
     */
    default int batchLogicDelete(Collection<Long> ids) {
        return this.logicDeleteByPrimaryKeys(ids);
    }

    /**
     * 验证实体存在性
     * @param id 主键
     * @return 实体对象
     */
    default CgmsCompanionOfflineOrderReport validate(Long id) {
        if (ObjectUtil.isNull(id)) {
            throw new UcodeServiceException(GlobalResultCodeEnum.VALIDATE_FAILED);
        }
        //验证数据是否存在
        CgmsCompanionOfflineOrderReport bean = this.selectByPrimaryKey(id);
        if (ObjectUtil.isNull(bean) || bean.getDeltag()) {
            throw new UcodeServiceException(CgmsSysResultCodeEnum.OFFLINE_ORDER_REPORT_NOT_EXISTS);
        }
        return bean;
    }
} 